package com.cloudlinkscm.base.authcenter.dao;

import com.cloudlinkscm.base.authcenter.mapper.RoleMapper;
import com.cloudlinkscm.base.authcenter.model.Role;
import com.cloudlinkscm.loms.framework.dao.GenericBizDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.entity.Example;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @author : tac
 * @date : 28/07/2017
 */
@Repository
public class RoleDao extends GenericBizDao<Role, String> {
    @Autowired
    public RoleDao(RoleMapper mapper) {
        super(mapper);
    }

    public List<Role> listByUserId(){
        //todo::
        return new ArrayList<>();
    }

    public int enable(String id) {
        //todo::
        return 0;
    }

    public int disalbe(String id) {
        //todo::
        return 0;
    }

    public Role selectByRoleNameAndTenantId(String roleName) {

    	Role role = new Role();
	    role.setRoleName(roleName);
    	return selectOne(role);
    }

    public List<Role> selectByTenantId(String tenantId) {
	    Role role = new Role();
	    role.setTenantId(tenantId);
	    return select(role);
    }

	public List<Role> selectByIds(Collection<String> roles) {
    	Example example = new Example(Role.class);
    	example.createCriteria().andIn("id", roles);
    	return selectByExample(example);
	}
}
